/*     */ import java.awt.Color;
/*     */ import java.awt.Container;
/*     */ import java.awt.Dimension;
/*     */ import java.awt.Font;
/*     */ import java.awt.Graphics;
/*     */ import java.awt.Graphics2D;
/*     */ import java.awt.Insets;
/*     */ import java.awt.event.ActionEvent;
/*     */ import java.awt.event.ActionListener;
/*     */ import java.awt.event.MouseEvent;
/*     */ import java.awt.event.MouseMotionListener;
import java.awt.geom.Line2D;
/*     */ import java.awt.geom.Line2D.Double;
import java.awt.geom.Rectangle2D;
/*     */ import java.text.DecimalFormat;
/*     */ import java.util.List;
/*     */ import javax.swing.BorderFactory;
/*     */ import javax.swing.Box;
/*     */ import javax.swing.BoxLayout;
/*     */ import javax.swing.JButton;
/*     */ import javax.swing.JDialog;
/*     */ import javax.swing.JFrame;
/*     */ import javax.swing.JLabel;
/*     */ import javax.swing.JOptionPane;
/*     */ import javax.swing.JPanel;
/*     */ import javax.swing.JTextField;
import javax.swing.border.TitledBorder;
/*     */ 
/*     */ public class CandleStickChart extends JPanel
/*     */   implements MouseMotionListener, ActionListener
/*     */ {
/*     */   private SymQuotes sq;
/*     */   private String sym;
/*  14 */   private float yScale = 1.0F;
/*  15 */   private float xScale = 1.0F;
/*     */   private double stickWidth;
/*     */   private float minVal;
/*     */   private float maxVal;
/*     */   private double recStartX;
/*     */   private double recStartY;
/*     */   private double recHeight;
/*     */   private double lTopStartX;
/*     */   private double lTopStartY;
/*     */   private double lTopEndX;
/*     */   private double lTopEndY;
/*     */   private double lBotStartX;
/*     */   private double lBotStartY;
/*     */   private double lBotEndX;
/*     */   private double lBotEndY;
/*     */   private float[] bBanTop;
/*     */   private float[] bBanBot;
/*     */   private float[] maEnvTop;
/*     */   private float[] maEnvBot;
/*     */   private int bb_P;
/*     */   private int bb_Q;
/*     */   private int mae_P;
/*     */   private int mae_Q;
/*  23 */   private String m = "";
/*     */   private int mX;
/*     */   private int mY;
/*  25 */   public int noOfDays = 150;
/*     */   private int noBullish;
/*     */   private JTextField bb_PTF;
/*     */   private JTextField bb_QTF;
/*     */   private JTextField mae_PTF;
/*     */   private JTextField mae_QTF;
/*     */   private JButton chgParmOk;
/*     */   private JButton chgParmCancel;
/*     */   private JButton defaultParms;
/*     */   private JDialog chgParmDialog;
/*  33 */   private DecimalFormat df = new DecimalFormat("0.00");
/*     */   public CandleStickChart.EastPanel ep;
/*     */   private double refY;
/*     */   private double refX;
/* 594 */   private Font ssp10 = new Font("SansSerif", 0, 10);
/* 595 */   private Font ssp9 = new Font("SansSerif", 0, 9);
/* 596 */   private Line2D.Double refL1 = new Line2D.Double();
/* 597 */   private Line2D.Double refL2 = new Line2D.Double();
/* 598 */   private Line2D.Double gridY = new Line2D.Double();
/* 599 */   private Line2D.Double yrefL1 = new Line2D.Double();
/* 600 */   private Line2D.Double yrefL2 = new Line2D.Double();
/* 601 */   private Line2D.Double gridX = new Line2D.Double();
/*     */   private double yfactor;
/*     */   private double startPointX;
/*     */   private int dateRef;
/*     */   private int daysRef;
/* 606 */   private Rectangle2D.Double rec = new Rectangle2D.Double();
/* 607 */   private Line2D.Double lTop = new Line2D.Double();
/* 608 */   private Line2D.Double lBot = new Line2D.Double();
/*     */   private double p1YT;
/*     */   private double p2YT;
/*     */   private double p1YB;
/*     */   private double p2YB;
/* 610 */   private Line2D.Double l1 = new Line2D.Double();
/* 611 */   private Line2D.Double l2 = new Line2D.Double();
/* 612 */   private Line2D.Double rec1 = new Line2D.Double();
/*     */ 
/*     */   public CandleStickChart(SymQuotes paramSymQuotes, int paramInt1, int paramInt2, int paramInt3, int paramInt4, int paramInt5)
/*     */   {
/*  39 */     this.sq = paramSymQuotes;
/*  40 */     this.sym = paramSymQuotes.sym;
/*  41 */     this.noBullish = paramInt1;
/*     */ 
/*  43 */     this.bBanTop = new float[paramSymQuotes.count];
/*  44 */     this.bBanBot = new float[paramSymQuotes.count];
/*  45 */     this.maEnvTop = new float[paramSymQuotes.count];
/*  46 */     this.maEnvBot = new float[paramSymQuotes.count];
/*     */ 
/*  48 */     this.bb_P = paramInt2;
/*  49 */     this.bb_Q = paramInt3;
/*  50 */     this.mae_P = paramInt4;
/*  51 */     this.mae_Q = paramInt5;
/*     */ 
/*  53 */     if (this.noOfDays == 150)
/*  54 */       this.stickWidth = (4.0F * this.xScale);
/*     */     else {
/*  56 */       this.stickWidth = (1.5D * this.xScale);
/*     */     }
/*  58 */     setBackground(Color.black);
/*  59 */     setPreferredSize(new Dimension((int)(750.0F * this.xScale + 100.0F), (int)(200.0F * this.yScale + 25.0F)));
/*     */ 
/*  61 */     bollingerBand(paramInt2, paramInt3);
/*  62 */     maEnvelope(paramInt4, paramInt5);
/*  63 */     findMinMax();
/*     */ 
/*  65 */     addMouseMotionListener(this);
/*     */ 
/*  67 */     this.ep = new CandleStickChart.EastPanel();
/*     */   }
/*     */ 
/*     */   public void redrawChart(SymQuotes paramSymQuotes, int paramInt)
/*     */   {
/*  74 */     this.sq = paramSymQuotes;
/*  75 */     this.sym = paramSymQuotes.sym;
/*  76 */     this.noBullish = paramInt;
/*     */ 
/*  78 */     this.bBanTop = new float[paramSymQuotes.count];
/*  79 */     this.bBanBot = new float[paramSymQuotes.count];
/*  80 */     this.maEnvTop = new float[paramSymQuotes.count];
/*  81 */     this.maEnvBot = new float[paramSymQuotes.count];
/*     */ 
/*  83 */     if (this.noOfDays == 150)
/*  84 */       this.stickWidth = (4.0F * this.xScale);
/*     */     else {
/*  86 */       this.stickWidth = (1.5D * this.xScale);
/*     */     }
/*  88 */     bollingerBand(this.bb_P, this.bb_Q);
/*  89 */     maEnvelope(this.mae_P, this.mae_Q);
/*  90 */     findMinMax();
/*     */ 
/*  92 */     repaint();
/*  93 */     this.ep.updateValues();
/*     */   }
/*     */ 
/*     */   public void redrawChart()
/*     */   {
/* 100 */     bollingerBand(this.bb_P, this.bb_Q);
/* 101 */     maEnvelope(this.mae_P, this.mae_Q);
/* 102 */     findMinMax();
/* 103 */     repaint();
/*     */   }
/*     */ 
/*     */   public void updateSummary(int paramInt)
/*     */   {
/* 110 */     this.noBullish = paramInt;
/* 111 */     this.ep.updateValues();
/*     */   }
/*     */ 
/*     */   public void changeNoOfDays(int paramInt)
/*     */   {
/* 118 */     this.noOfDays = paramInt;
/*     */ 
/* 120 */     if (paramInt == 150)
/* 121 */       this.stickWidth = (4.0F * this.xScale);
/*     */     else
/* 123 */       this.stickWidth = (1.5D * this.xScale);
/* 124 */     findMinMax();
/*     */   }
/*     */ 
/*     */   public void mouseMoved(MouseEvent paramMouseEvent)
/*     */   {
/* 132 */     int j = 1;
/* 133 */     if ((paramMouseEvent.getX() >= 50) && (paramMouseEvent.getX() <= 750.0F * this.xScale + 50.0F) && (paramMouseEvent.getY() >= 10) && (paramMouseEvent.getY() <= this.yScale * 200.0F + 10.0F))
/*     */     {
/* 135 */       int i = (int)((750.0F * this.xScale - (paramMouseEvent.getX() - 50) - this.stickWidth / 2.0D) / (this.stickWidth + 1.0F * this.xScale));
/*     */ 
/* 137 */       if (this.sq.count - 1 >= i) {
/* 138 */         j = this.sq.count - 1 - i;
/*     */ 
/* 140 */         if (this.sq.sd.equals("ns"))
/*     */         {
/* 142 */           this.m = ("(" + (String)this.sq.date.get(j) + ", O:" + this.sq.open.get(j) + ", H:" + this.sq.high.get(j) + ", L:" + this.sq.low.get(j) + ", C:" + this.sq.close.get(j) + ")");
/*     */         }
/* 146 */         else if (j < this.sq.date.indexOf(this.sq.sd))
/*     */         {
/* 148 */           float f = this.sq.asq / this.sq.bsq;
/* 149 */           this.m = ("(" + (String)this.sq.date.get(j) + ", O:" + this.df.format(((Float)this.sq.open.get(j)).floatValue() * f) + ", H:" + this.df.format(((Float)this.sq.high.get(j)).floatValue() * f) + ", L:" + this.df.format(((Float)this.sq.low.get(j)).floatValue() * f) + ", C:" + this.df.format(((Float)this.sq.close.get(j)).floatValue() * f) + ")");
/*     */         }
/*     */         else
/*     */         {
/* 154 */           this.m = ("(" + (String)this.sq.date.get(j) + ", O:" + this.sq.open.get(j) + ", H:" + this.sq.high.get(j) + ", L:" + this.sq.low.get(j) + ", C:" + this.sq.close.get(j) + ")");
/*     */         }
/*     */ 
/* 161 */         this.mX = paramMouseEvent.getX();
/* 162 */         this.mY = paramMouseEvent.getY();
/* 163 */         repaint();
/* 164 */         return;
/*     */       }
/*     */ 
/* 167 */       this.m = "";
/* 168 */       repaint();
/* 169 */       return;
/*     */     }
/*     */ 
/* 173 */     this.m = "";
/* 174 */     repaint();
/*     */   }
/*     */ 
/*     */   public void mouseDragged(MouseEvent paramMouseEvent)
/*     */   {
/*     */   }
/*     */ 
/*     */   private void drawValues(Graphics2D paramGraphics2D)
/*     */   {
/* 187 */     paramGraphics2D.setPaint(Color.cyan);
/*     */ 
/* 189 */     if (this.mX + this.m.length() * 5 > 750.0F * this.xScale + 50.0F) {
/* 190 */       this.mX -= this.m.length() * 5;
/*     */     }
/* 192 */     paramGraphics2D.drawString(this.m, this.mX, this.mY);
/*     */   }
/*     */ 
/*     */   private void maEnvelope(int paramInt1, int paramInt2)
/*     */   {
/* 200 */     for (int i = paramInt1; i < this.sq.count; i++)
/*     */     {
/* 202 */       float f2 = 0.0F;
/* 203 */       for (int j = i; j >= i - (paramInt1 - 1); j--)
/*     */       {
/* 205 */         f2 += ((Float)this.sq.close.get(j)).floatValue();
/*     */       }
/* 207 */       float f1 = f2 / paramInt1;
/*     */ 
/* 209 */       this.maEnvTop[i] = (f1 + f1 * paramInt2 / 100.0F);
/* 210 */       this.maEnvBot[i] = (f1 - f1 * paramInt2 / 100.0F);
/*     */     }
/*     */   }
/*     */ 
/*     */   private void bollingerBand(int paramInt1, int paramInt2)
/*     */   {
/* 218 */     for (int i = paramInt1; i < this.sq.count; i++)
/*     */     {
/* 220 */       float f4 = 0.0F;
/* 221 */       for (int j = i; j >= i - (paramInt1 - 1); j--)
/*     */       {
/* 223 */         f4 += ((Float)this.sq.close.get(j)).floatValue();
/*     */       }
/* 225 */       float f1 = f4 / paramInt1;
/*     */ 
/* 227 */       float f5 = 0.0F;
/* 228 */       for (int k = i; k >= i - (paramInt1 - 1); k--)
/*     */       {
/* 230 */         f5 = (float)(f5 + Math.pow(Math.abs(f1 - ((Float)this.sq.close.get(k)).floatValue()), 2.0D));
/*     */       }
/*     */ 
/* 233 */       float f2 = (float)Math.sqrt(f5 / paramInt1);
/*     */ 
/* 235 */       float f3 = paramInt2 * f2;
/*     */ 
/* 237 */       this.bBanTop[i] = (f1 + f3);
/* 238 */       this.bBanBot[i] = (f1 - f3);
/*     */     }
/*     */   }
/*     */ 
/*     */   public void updateBolBanParms(int paramInt1, int paramInt2)
/*     */   {
/* 245 */     this.bb_P = paramInt1;
/* 246 */     this.bb_Q = paramInt2;
/*     */ 
/* 248 */     bollingerBand(paramInt1, paramInt2);
/* 249 */     findMinMax();
/*     */   }
/*     */ 
/*     */   public void updateMAEnvParms(int paramInt1, int paramInt2)
/*     */   {
/* 256 */     this.mae_P = paramInt1;
/* 257 */     this.mae_Q = paramInt2;
/*     */ 
/* 259 */     maEnvelope(paramInt1, paramInt2);
/* 260 */     findMinMax();
/*     */   }
/*     */ 
/*     */   public void changeParms(int paramInt1, int paramInt2, int paramInt3, int paramInt4)
/*     */   {
/* 267 */     this.bb_P = paramInt1;
/* 268 */     this.bb_Q = paramInt2;
/* 269 */     this.mae_P = paramInt3;
/* 270 */     this.mae_Q = paramInt4;
/*     */ 
/* 272 */     bollingerBand(paramInt1, paramInt2);
/* 273 */     maEnvelope(paramInt3, paramInt4);
/* 274 */     findMinMax();
/* 275 */     repaint();
/*     */   }
/*     */ 
/*     */   public Box getBollingerBandsBox(boolean paramBoolean)
/*     */   {
/* 282 */     Box localBox = Box.createHorizontalBox();
/* 283 */     TitledBorder localTitledBorder = BorderFactory.createTitledBorder("Bollinger Bands");
/*     */ 
/* 285 */     this.bb_PTF = new JTextField("" + this.bb_P, 2);
/* 286 */     this.bb_QTF = new JTextField("" + this.bb_Q, 2);
/* 287 */     this.bb_PTF.setFont(this.ssp10);
/* 288 */     this.bb_QTF.setFont(this.ssp10);
/* 289 */     this.bb_PTF.setMaximumSize(new Dimension(25, 20));
/* 290 */     this.bb_QTF.setMaximumSize(new Dimension(25, 20));
/*     */ 
/* 292 */     JLabel localJLabel1 = new JLabel("Boll. Bands[");
/* 293 */     JLabel localJLabel2 = new JLabel(" ,  ");
/* 294 */     JLabel localJLabel3 = new JLabel("]     ");
/* 295 */     localJLabel1.setFont(this.ssp10);
/* 296 */     localJLabel2.setFont(this.ssp10);
/* 297 */     localJLabel3.setFont(this.ssp10);
/*     */ 
/* 299 */     localBox.add(localJLabel1);
/* 300 */     localBox.add(this.bb_PTF);
/* 301 */     localBox.add(localJLabel2);
/* 302 */     localBox.add(this.bb_QTF);
/* 303 */     localBox.add(localJLabel3);
/*     */ 
/* 305 */     localBox.add(Box.createHorizontalGlue());
/*     */ 
/* 307 */     if (paramBoolean) {
/* 308 */       localBox.setBorder(localTitledBorder);
/*     */     }
/* 310 */     return localBox;
/*     */   }
/*     */ 
/*     */   public Box getMaEnvelopesBox(boolean paramBoolean)
/*     */   {
/* 317 */     Box localBox = Box.createHorizontalBox();
/* 318 */     TitledBorder localTitledBorder = BorderFactory.createTitledBorder("MA Envelopes");
/*     */ 
/* 320 */     this.mae_PTF = new JTextField("" + this.mae_P, 2);
/* 321 */     this.mae_QTF = new JTextField("" + this.mae_Q, 2);
/* 322 */     this.mae_PTF.setFont(this.ssp10);
/* 323 */     this.mae_QTF.setFont(this.ssp10);
/* 324 */     this.mae_PTF.setMaximumSize(new Dimension(25, 20));
/* 325 */     this.mae_QTF.setMaximumSize(new Dimension(25, 20));
/*     */ 
/* 327 */     JLabel localJLabel1 = new JLabel("MA Envs.[");
/* 328 */     JLabel localJLabel2 = new JLabel(" ,  ");
/* 329 */     JLabel localJLabel3 = new JLabel("]     ");
/* 330 */     localJLabel1.setFont(this.ssp10);
/* 331 */     localJLabel2.setFont(this.ssp10);
/* 332 */     localJLabel3.setFont(this.ssp10);
/*     */ 
/* 334 */     localBox.add(localJLabel1);
/* 335 */     localBox.add(this.mae_PTF);
/* 336 */     localBox.add(localJLabel2);
/* 337 */     localBox.add(this.mae_QTF);
/* 338 */     localBox.add(localJLabel3);
/*     */ 
/* 340 */     localBox.add(Box.createHorizontalGlue());
/*     */ 
/* 342 */     if (paramBoolean) {
/* 343 */       localBox.setBorder(localTitledBorder);
/*     */     }
/* 345 */     return localBox;
/*     */   }
/*     */ 
/*     */   private void showChgParmDialog()
/*     */   {
/* 352 */     JFrame localJFrame = new JFrame();
/* 353 */     this.chgParmDialog = new JDialog(localJFrame, "Change Parameters", true);
/* 354 */     Box localBox1 = Box.createVerticalBox();
/* 355 */     Box localBox2 = Box.createHorizontalBox();
/*     */ 
/* 357 */     this.chgParmOk = new JButton("OK");
/* 358 */     this.chgParmOk.setFont(this.ssp10);
/* 359 */     this.chgParmOk.setMargin(new Insets(1, 2, 1, 2));
/* 360 */     this.chgParmOk.addActionListener(this);
/*     */ 
/* 362 */     this.chgParmCancel = new JButton("Cancel");
/* 363 */     this.chgParmCancel.setFont(this.ssp10);
/* 364 */     this.chgParmCancel.setMargin(new Insets(1, 2, 1, 2));
/* 365 */     this.chgParmCancel.addActionListener(this);
/*     */ 
/* 367 */     this.defaultParms = new JButton("Default");
/* 368 */     this.defaultParms.setFont(this.ssp10);
/* 369 */     this.defaultParms.setMargin(new Insets(1, 2, 1, 2));
/* 370 */     this.defaultParms.setToolTipText("Reset to default parameters");
/* 371 */     this.defaultParms.addActionListener(this);
/*     */ 
/* 373 */     localBox2.add(Box.createHorizontalGlue());
/* 374 */     localBox2.add(this.chgParmOk);
/* 375 */     localBox2.add(Box.createHorizontalStrut(5));
/* 376 */     localBox2.add(this.chgParmCancel);
/* 377 */     localBox2.add(Box.createHorizontalStrut(5));
/* 378 */     localBox2.add(this.defaultParms);
/* 379 */     localBox2.add(Box.createHorizontalGlue());
/*     */ 
/* 381 */     localBox1.add(getBollingerBandsBox(true));
/* 382 */     localBox1.add(getMaEnvelopesBox(true));
/* 383 */     localBox1.add(localBox2);
/*     */ 
/* 385 */     this.chgParmDialog.getContentPane().add(localBox1);
/* 386 */     this.chgParmDialog.setSize(250, 150);
/* 387 */     this.chgParmDialog.setLocationRelativeTo(this.ep);
/* 388 */     this.chgParmDialog.setVisible(true);
/*     */   }
/*     */ 
/*     */   public void actionPerformed(ActionEvent paramActionEvent)
/*     */   {
/* 395 */     if (paramActionEvent.getSource() == this.chgParmOk)
/*     */     {
/* 397 */       if (!validateParm()) {
/* 398 */         return;
/*     */       }
/* 400 */       redrawChart();
/* 401 */       this.chgParmDialog.dispose();
/*     */     }
/*     */ 
/* 405 */     if (paramActionEvent.getSource() == this.chgParmCancel)
/*     */     {
/* 407 */       this.chgParmDialog.dispose();
/*     */     }
/*     */ 
/* 411 */     if (paramActionEvent.getSource() == this.defaultParms)
/*     */     {
/* 413 */       setDefaultParms();
/*     */     }
/*     */   }
/*     */ 
/*     */   public void setDefaultParms()
/*     */   {
/* 422 */     this.bb_PTF.setText("20");
/* 423 */     this.bb_QTF.setText("2");
/* 424 */     this.mae_PTF.setText("20");
/* 425 */     this.mae_QTF.setText("6");
/*     */   }
/*     */ 
/*     */   public boolean validateParm()
/*     */   {
/*     */     int i;
/*     */     int j;
/*     */     try
/*     */     {
/* 436 */       i = Integer.parseInt(this.bb_PTF.getText().trim());
/* 437 */       j = Integer.parseInt(this.bb_QTF.getText().trim());
/*     */     }
/*     */     catch (NumberFormatException localNumberFormatException1)
/*     */     {
/* 443 */       JOptionPane.showMessageDialog(null, "Error in Bollinger Bands parameter.Enter only numbers greater than 2.", null, 0);
/*     */ 
/* 447 */       this.bb_PTF.setText("" + this.bb_P);
/* 448 */       this.bb_QTF.setText("" + this.bb_Q);
/*     */ 
/* 450 */       return false;
/*     */     }
/*     */ 
/* 454 */     if ((i > 200) || (j > 200))
/*     */     {
/* 456 */       JOptionPane.showMessageDialog(null, "Error in Bollinger Bands parameter.Enter values between 2 and 200.", null, 0);
/*     */ 
/* 460 */       this.bb_PTF.setText("" + this.bb_P);
/* 461 */       this.bb_QTF.setText("" + this.bb_Q);
/*     */ 
/* 463 */       return false;
/*     */     }
/*     */ 
/* 466 */     if ((i < 2) || (j < 2))
/*     */     {
/* 468 */       JOptionPane.showMessageDialog(null, "Error in Bollinger Bands parameter.Enter values between 2 and 200.", null, 0);
/*     */ 
/* 472 */       this.bb_PTF.setText("" + this.bb_P);
/* 473 */       this.bb_QTF.setText("" + this.bb_Q);
/*     */ 
/* 475 */       return false;
/*     */     }int k;
/*     */     int n;
/*     */     try {
/* 481 */       k = Integer.parseInt(this.mae_PTF.getText().trim());
/* 482 */       n = Integer.parseInt(this.mae_QTF.getText().trim());
/*     */     }
/*     */     catch (NumberFormatException localNumberFormatException2)
/*     */     {
/* 488 */       JOptionPane.showMessageDialog(null, "Error in MA Envelopes parameter.Enter only numbers greater than 2.", null, 0);
/*     */ 
/* 492 */       this.mae_PTF.setText("" + this.mae_P);
/* 493 */       this.mae_QTF.setText("" + this.mae_Q);
/*     */ 
/* 495 */       return false;
/*     */     }
/*     */ 
/* 499 */     if ((k > 200) || (n > 200))
/*     */     {
/* 501 */       JOptionPane.showMessageDialog(null, "Error in MA Envelopes parameter.Enter values between 2 and 200.", null, 0);
/*     */ 
/* 505 */       this.mae_PTF.setText("" + this.mae_P);
/* 506 */       this.mae_QTF.setText("" + this.mae_Q);
/*     */ 
/* 508 */       return false;
/*     */     }
/*     */ 
/* 511 */     if ((k < 2) || (n < 2))
/*     */     {
/* 513 */       JOptionPane.showMessageDialog(null, "Error in MA Envelopes parameter.Enter values between 2 and 200.", null, 0);
/*     */ 
/* 517 */       this.mae_PTF.setText("" + this.mae_P);
/* 518 */       this.mae_QTF.setText("" + this.mae_Q);
/*     */ 
/* 520 */       return false;
/*     */     }
/*     */ 
/* 523 */     this.bb_P = i;
/* 524 */     this.bb_Q = j;
/* 525 */     this.mae_P = k;
/* 526 */     this.mae_Q = n;
/*     */ 
/* 528 */     return true;
/*     */   }
/*     */ 
/*     */   public void vZoom(boolean paramBoolean)
/*     */   {
/* 535 */     if (paramBoolean)
/* 536 */       this.yScale += 0.2F;
/* 537 */     else if (this.yScale >= 1.2D) {
/* 538 */       this.yScale -= 0.2F;
/*     */     }
/* 540 */     setPreferredSize(new Dimension((int)(750.0F * this.xScale + 100.0F), (int)(200.0F * this.yScale + 25.0F)));
/*     */   }
/*     */ 
/*     */   public void hZoom(boolean paramBoolean)
/*     */   {
/* 547 */     if (paramBoolean)
/* 548 */       this.xScale += 0.2F;
/* 549 */     else if (this.xScale >= 1.2D) {
/* 550 */       this.xScale -= 0.2F;
/*     */     }
/* 552 */     if (this.noOfDays == 150)
/* 553 */       this.stickWidth = (4.0F * this.xScale);
/*     */     else
/* 555 */       this.stickWidth = (1.5D * this.xScale);
/* 556 */     setPreferredSize(new Dimension((int)(750.0F * this.xScale + 100.0F), (int)(200.0F * this.yScale + 25.0F)));
/*     */   }
/*     */ 
/*     */   public void resetZoom()
/*     */   {
/* 563 */     this.yScale = 1.0F;
/* 564 */     this.xScale = 1.0F;
/* 565 */     if (this.noOfDays == 150)
/* 566 */       this.stickWidth = (4.0F * this.xScale);
/*     */     else
/* 568 */       this.stickWidth = (1.5D * this.xScale);
/* 569 */     setPreferredSize(new Dimension((int)(750.0F * this.xScale + 100.0F), (int)(200.0F * this.yScale + 25.0F)));
/*     */   }
/*     */ 
/*     */   protected void clear(Graphics paramGraphics)
/*     */   {
/* 577 */     super.paintComponent(paramGraphics);
/*     */   }
/*     */ 
/*     */   protected void paintComponent(Graphics paramGraphics)
/*     */   {
/* 584 */     clear(paramGraphics);
/* 585 */     Graphics2D localGraphics2D = (Graphics2D)paramGraphics;
/* 586 */     drawChart(localGraphics2D);
/* 587 */     drawValues(localGraphics2D);
/*     */   }
/*     */ 
/*     */   private void drawChart(Graphics2D paramGraphics2D)
/*     */   {
/* 617 */     this.refY = 10.0D;
/* 618 */     this.refX = 50.0D;
/* 619 */     setFont(this.ssp10);
/* 620 */     String str = "Bollinger Bands[" + this.bb_P + "," + this.bb_Q + "]";
/* 621 */     paramGraphics2D.setPaint(new Color(190, 100, 200));
/* 622 */     paramGraphics2D.drawString(str, 50, 10);
/*     */ 
/* 624 */     str = "MA Envelopes[" + this.mae_P + "," + this.mae_Q + "]";
/* 625 */     paramGraphics2D.setPaint(new Color(220, 170, 40));
/* 626 */     paramGraphics2D.drawString(str, 160, 10);
/*     */ 
/* 629 */     this.refL1.setLine(50.0D, 10.0D, 50.0D, this.yScale * 200.0F + 10.0F);
/* 630 */     this.refL2.setLine(750.0F * this.xScale + 50.0F, 10.0D, 750.0F * this.xScale + 50.0F, this.yScale * 200.0F + 10.0F);
/* 631 */     paramGraphics2D.setPaint(Color.white);
/* 632 */     paramGraphics2D.draw(this.refL1);
/* 633 */     paramGraphics2D.draw(this.refL2);
/*     */ 
/* 635 */     for (int i = 0; i < 14; i++)
/*     */     {
/* 637 */       this.refX += 50.0F * this.xScale;
/* 638 */       this.gridY.setLine(this.refX, 10.0D, this.refX, this.yScale * 200.0F + 10.0F);
/* 639 */       paramGraphics2D.setPaint(Color.darkGray);
/* 640 */       paramGraphics2D.draw(this.gridY);
/*     */     }
int i;
/*     */ 
/* 644 */     for (i = 0; i < 11; i++)
/*     */     {
/* 646 */       this.yrefL1.setLine(50.0D, this.refY, 40.0D, this.refY);
/* 647 */       str = this.df.format(this.maxVal - (this.maxVal - this.minVal) / 10.0F * i);
/* 648 */       paramGraphics2D.setPaint(Color.lightGray);
/* 649 */       paramGraphics2D.drawString(str, 10, (int)this.refY);
/* 650 */       this.yrefL2.setLine(750.0F * this.xScale + 50.0F, this.refY, 750.0F * this.xScale + 60.0F, this.refY);
/*     */ 
/* 652 */       paramGraphics2D.drawString(str, (int)(750.0F * this.xScale + 51.0F), (int)this.refY);
/* 653 */       this.gridX.setLine(50.0D, this.refY, 750.0F * this.xScale + 50.0F, this.refY);
/* 654 */       paramGraphics2D.setPaint(Color.white);
/* 655 */       paramGraphics2D.draw(this.yrefL1);
/* 656 */       paramGraphics2D.draw(this.yrefL2);
/* 657 */       paramGraphics2D.setPaint(Color.darkGray);
/* 658 */       paramGraphics2D.draw(this.gridX);
/* 659 */       this.refY += 20.0F * this.yScale;
/*     */     }
/*     */ 
/* 663 */     this.yfactor = (this.yScale * 200.0F / (this.maxVal - this.minVal));
/* 664 */     this.startPointX = (750.0F * this.xScale + 50.0F - (this.stickWidth + 1.0F * this.xScale));
/* 665 */     this.dateRef = (this.sq.count - 1);
/* 666 */     this.daysRef = 1;
/*     */ 
/* 668 */     for (i = this.sq.count - 1; i >= 0; i--)
/*     */     {
/* 670 */       if (this.daysRef == this.noOfDays) {
/*     */         break;
/*     */       }
/* 673 */       this.lBotStartY = (this.yScale * 200.0F + 10.0F - (((Float)this.sq.low.get(i)).floatValue() - this.minVal) * this.yfactor);
/* 674 */       this.lTopStartY = (this.yScale * 200.0F + 10.0F - (((Float)this.sq.high.get(i)).floatValue() - this.minVal) * this.yfactor);
/* 675 */       this.recStartX = (this.startPointX - (int)this.stickWidth / 2);
/*     */ 
/* 677 */       if (((Float)this.sq.open.get(i)).floatValue() > ((Float)this.sq.close.get(i)).floatValue())
/*     */       {
/* 679 */         this.recStartY = (this.yScale * 200.0F + 10.0F - (((Float)this.sq.open.get(i)).floatValue() - this.minVal) * this.yfactor);
/* 680 */         this.recHeight = ((((Float)this.sq.open.get(i)).floatValue() - ((Float)this.sq.close.get(i)).floatValue()) * this.yfactor);
/* 681 */         this.lTopEndY = this.recStartY;
/* 682 */         this.lBotEndY = (this.recStartY + this.recHeight);
/* 683 */         this.rec.setRect(this.recStartX, this.recStartY, this.stickWidth, this.recHeight + 1.0D);
/* 684 */         this.lTop.setLine(this.startPointX, this.lTopStartY, this.startPointX, this.lTopEndY);
/* 685 */         this.lBot.setLine(this.startPointX, this.lBotStartY, this.startPointX, this.lBotEndY);
/* 686 */         paramGraphics2D.setPaint(Color.red);
/*     */ 
/* 689 */         paramGraphics2D.fill(this.rec);
/*     */ 
/* 693 */         paramGraphics2D.draw(this.lTop);
/* 694 */         paramGraphics2D.draw(this.lBot);
/*     */       }
/*     */ 
/* 698 */       if (((Float)this.sq.open.get(i)).floatValue() < ((Float)this.sq.close.get(i)).floatValue())
/*     */       {
/* 700 */         this.recStartY = (this.yScale * 200.0F + 10.0F - (((Float)this.sq.close.get(i)).floatValue() - this.minVal) * this.yfactor);
/* 701 */         this.recHeight = ((((Float)this.sq.close.get(i)).floatValue() - ((Float)this.sq.open.get(i)).floatValue()) * this.yfactor);
/* 702 */         this.lTopEndY = this.recStartY;
/* 703 */         this.lBotEndY = (this.recStartY + this.recHeight);
/* 704 */         this.rec.setRect(this.recStartX, this.recStartY, this.stickWidth, this.recHeight);
/* 705 */         this.lTop.setLine(this.startPointX, this.lTopStartY, this.startPointX, this.lTopEndY);
/* 706 */         this.lBot.setLine(this.startPointX, this.lBotStartY, this.startPointX, this.lBotEndY);
/* 707 */         paramGraphics2D.setPaint(Color.green);
/* 708 */         paramGraphics2D.draw(this.rec);
/* 709 */         paramGraphics2D.draw(this.lTop);
/* 710 */         paramGraphics2D.draw(this.lBot);
/*     */       }
/*     */ 
/* 714 */       if (((Float)this.sq.open.get(i)).floatValue() == ((Float)this.sq.close.get(i)).floatValue())
/*     */       {
/* 716 */         this.lTopEndY = (this.yScale * 200.0F + 10.0F - (((Float)this.sq.close.get(i)).floatValue() - this.minVal) * this.yfactor);
/* 717 */         this.lBotEndY = this.lTopEndY;
/* 718 */         this.rec1.setLine(this.recStartX, this.lTopEndY, this.recStartX + this.stickWidth, this.lTopEndY);
/* 719 */         this.lTop.setLine(this.startPointX, this.lTopStartY, this.startPointX, this.lTopEndY);
/* 720 */         this.lBot.setLine(this.startPointX, this.lBotStartY, this.startPointX, this.lBotEndY);
/* 721 */         paramGraphics2D.setPaint(Color.green);
/* 722 */         paramGraphics2D.draw(this.rec);
/* 723 */         paramGraphics2D.draw(this.lTop);
/* 724 */         paramGraphics2D.draw(this.lBot);
/*     */       }
/*     */ 
/* 728 */       if (this.dateRef == i)
/*     */       {
/* 730 */         paramGraphics2D.setFont(this.ssp9);
/* 731 */         str = ((String)this.sq.date.get(i)).substring(0, 6);
/* 732 */         paramGraphics2D.drawString(str, (int)this.recStartX, (int)(this.yScale * 200.0F + 20.0F));
/* 733 */         if (this.noOfDays == 150)
/* 734 */           this.dateRef -= 10;
/*     */         else
/* 736 */           this.dateRef -= 20;
/* 737 */         paramGraphics2D.setFont(this.ssp10);
/*     */       }
/*     */ 
/* 741 */       if (i > this.bb_P)
/*     */       {
/* 743 */         this.p1YT = (this.yScale * 200.0F + 10.0F - (this.bBanTop[i] - this.minVal) * this.yfactor);
/* 744 */         this.p2YT = (this.yScale * 200.0F + 10.0F - (this.bBanTop[(i - 1)] - this.minVal) * this.yfactor);
/*     */ 
/* 746 */         this.l1.setLine(this.startPointX, this.p1YT, this.startPointX - this.stickWidth - 1.0F * this.xScale, this.p2YT);
/* 747 */         paramGraphics2D.setPaint(new Color(190, 100, 200));
/* 748 */         paramGraphics2D.draw(this.l1);
/*     */ 
/* 750 */         this.p1YB = (this.yScale * 200.0F + 10.0F - (this.bBanBot[i] - this.minVal) * this.yfactor);
/* 751 */         this.p2YB = (this.yScale * 200.0F + 10.0F - (this.bBanBot[(i - 1)] - this.minVal) * this.yfactor);
/*     */ 
/* 753 */         this.l2.setLine(this.startPointX, this.p1YB, this.startPointX - this.stickWidth - 1.0F * this.xScale, this.p2YB);
/* 754 */         paramGraphics2D.draw(this.l2);
/*     */       }
/*     */ 
/* 758 */       if (i > this.mae_P)
/*     */       {
/* 760 */         this.p1YT = (this.yScale * 200.0F + 10.0F - (this.maEnvTop[i] - this.minVal) * this.yfactor);
/* 761 */         this.p2YT = (this.yScale * 200.0F + 10.0F - (this.maEnvTop[(i - 1)] - this.minVal) * this.yfactor);
/*     */ 
/* 763 */         this.l1.setLine(this.startPointX, this.p1YT, this.startPointX - this.stickWidth - 1.0F * this.xScale, this.p2YT);
/* 764 */         paramGraphics2D.setPaint(new Color(220, 170, 40));
/* 765 */         paramGraphics2D.draw(this.l1);
/*     */ 
/* 767 */         this.p1YB = (this.yScale * 200.0F + 10.0F - (this.maEnvBot[i] - this.minVal) * this.yfactor);
/* 768 */         this.p2YB = (this.yScale * 200.0F + 10.0F - (this.maEnvBot[(i - 1)] - this.minVal) * this.yfactor);
/*     */ 
/* 770 */         this.l2.setLine(this.startPointX, this.p1YB, this.startPointX - this.stickWidth - 1.0F * this.xScale, this.p2YB);
/* 771 */         paramGraphics2D.draw(this.l2);
/*     */       }
/*     */ 
/* 775 */       this.startPointX = (this.startPointX - this.stickWidth - 1.0F * this.xScale);
/* 776 */       this.daysRef += 1;
/*     */     }
/*     */   }
/*     */ 
/*     */   private void findMinMax()
/*     */   {
/* 787 */     int i = 1;
/* 788 */     this.minVal = ((Float)this.sq.low.get(this.sq.count - 1)).floatValue();
/* 789 */     this.maxVal = ((Float)this.sq.high.get(this.sq.count - 1)).floatValue();
/*     */ 
/* 791 */     for (int j = this.sq.count - 1; j >= 0; j--)
/*     */     {
/* 793 */       if (i > this.noOfDays) {
/*     */         break;
/*     */       }
/* 796 */       if (this.minVal > ((Float)this.sq.low.get(j)).floatValue()) {
/* 797 */         this.minVal = ((Float)this.sq.low.get(j)).floatValue();
/*     */       }
/* 799 */       if (this.maxVal < ((Float)this.sq.high.get(j)).floatValue()) {
/* 800 */         this.maxVal = ((Float)this.sq.high.get(j)).floatValue();
/*     */       }
/* 802 */       i += 1;
/*     */     }
/*     */ 
/* 806 */     i = 1;
/* 807 */     for (int j = this.sq.count - 1; j >= this.bb_P; j--)
/*     */     {
/* 809 */       if (i > this.noOfDays) {
/*     */         break;
/*     */       }
/* 812 */       if (this.minVal > this.bBanBot[j]) {
/* 813 */         this.minVal = this.bBanBot[j];
/*     */       }
/* 815 */       if (this.maxVal < this.bBanTop[j]) {
/* 816 */         this.maxVal = this.bBanTop[j];
/*     */       }
/* 818 */       i += 1;
/*     */     }
/*     */ 
/* 822 */     i = 1;
/* 823 */     for (int j = this.sq.count - 1; j >= this.mae_P; j--)
/*     */     {
/* 825 */       if (i > this.noOfDays) {
/*     */         break;
/*     */       }
/* 828 */       if (this.minVal > this.maEnvBot[j]) {
/* 829 */         this.minVal = this.maEnvBot[j];
/*     */       }
/* 831 */       if (this.maxVal < this.maEnvTop[j]) {
/* 832 */         this.maxVal = this.maEnvTop[j];
/*     */       }
/* 834 */       i += 1;
/*     */     }
/*     */   }
/*     */ 
/*     */   public static void main(String[] paramArrayOfString)
/*     */   {
/* 922 */     FileDownloader localFileDownloader = new FileDownloader();
/*     */ 
/* 924 */     localFileDownloader.downloadFiles();
/* 925 */     SymQuotes localSymQuotes = new SymQuotes("WIPRO", localFileDownloader.datesToRead, 1, 1, "ns");
/*     */ 
/* 928 */     CandleStickChart localCandleStickChart = new CandleStickChart(localSymQuotes, 6, 20, 2, 20, 6);
/*     */ 
/* 930 */     JFrame localJFrame = new JFrame("Test");
/* 931 */     localJFrame.setDefaultCloseOperation(3);
/* 932 */     localJFrame.getContentPane().add(localCandleStickChart);
/* 933 */     localJFrame.pack();
/* 934 */     localJFrame.setSize(850, 270);
/* 935 */     localJFrame.setVisible(true);
/*     */   }
/*     */ 
/*     */   public class EastPanel extends JPanel
/*     */     implements ActionListener
/*     */   {
/*     */     private JLabel title;
/*     */     private JLabel noBullishL;
/*     */     private JLabel noBearishL;
/*     */     private ChartHelpButton chb;
/* 847 */     private Font valuesF = new Font("Sanserif", 0, 11);
/*     */     private JButton chgParmButton;
/* 849 */     private Box buttonsPanel = Box.createHorizontalBox();
/*     */ 
/*     */     public EastPanel()
/*     */     {
/* 853 */       this.title = new JLabel(CandleStickChart.this.sq.sym);
/* 854 */       this.noBullishL = new JLabel("No of Bullish: " + CandleStickChart.this.noBullish);
/* 855 */       this.noBearishL = new JLabel("No of Bearish: " + (14 - CandleStickChart.this.noBullish));
/*     */ 
/* 857 */       this.chb = new ChartHelpButton("http://www.profitindicators.com/home/indicators/candlestickcharts.htm", "Help on Candlestick Charts");
/*     */ 
/* 859 */       this.chb.setFont(this.valuesF);
/*     */ 
/* 861 */       this.noBullishL.setFont(this.valuesF);
/* 862 */       this.noBearishL.setFont(this.valuesF);
/*     */ 
/* 864 */       this.chgParmButton = new JButton("Chg.Parm.");
/* 865 */       this.chgParmButton.setFont(this.valuesF);
/* 866 */       this.chgParmButton.setMargin(new Insets(1, 2, 1, 2));
/* 867 */       this.chgParmButton.addActionListener(this);
/* 868 */       this.chgParmButton.setToolTipText("Change parm. Bollinger Bands/MA Envelopes");
/*     */ 
/* 870 */       this.buttonsPanel.add(this.chb);
/* 871 */       this.buttonsPanel.add(Box.createHorizontalStrut(2));
/* 872 */       this.buttonsPanel.add(this.chgParmButton);
/* 873 */       this.buttonsPanel.setAlignmentX(0.0F);
/*     */ 
/* 875 */       setLayout(new BoxLayout(this, 1));
/*     */ 
/* 877 */       add(this.title);
/* 878 */       add(this.noBullishL);
/* 879 */       add(this.noBearishL);
/* 880 */       add(new JLabel(" "));
/* 881 */       add(new JLabel(" "));
/* 882 */       add(new JLabel(" "));
/* 883 */       add(new JLabel(" "));
/* 884 */       add(new JLabel(" "));
/* 885 */       add(new JLabel(" "));
/* 886 */       add(new JLabel(" "));
/* 887 */       add(new JLabel(" "));
/* 888 */       add(new JLabel(" "));
/* 889 */       add(this.buttonsPanel);
/* 890 */       add(Box.createVerticalGlue());
/*     */ 
/* 892 */       setBackground(new Color(243, 245, 252));
/*     */     }
/*     */ 
/*     */     public void updateValues()
/*     */     {
/* 899 */       this.title.setText(CandleStickChart.this.sq.sym);
/* 900 */       this.noBullishL.setText("No of Bullish: " + CandleStickChart.this.noBullish);
/* 901 */       this.noBearishL.setText("No of Bearish: " + (14 - CandleStickChart.this.noBullish));
/*     */     }
/*     */ 
/*     */     public void actionPerformed(ActionEvent paramActionEvent)
/*     */     {
/* 908 */       if (paramActionEvent.getSource() == this.chgParmButton)
/*     */       {
/* 910 */         CandleStickChart.this.showChgParmDialog();
/*     */       }
/*     */     }
/*     */   }
/*     */ }

/* Location:           C:\Users\Deebak\Downloads\profitindicatorsv2-05.jar
 * Qualified Name:     CandleStickChart
 * JD-Core Version:    0.6.0
 */